import 'package:flutter/material.dart';
import 'package:x3_base_core/x3_base_core.dart';
import 'package:x3_form_core/x3_form_core.dart';
///**
///* @fileName: business_customer_details_tag_edit_label_tab_form
///* @author: hrongyong
///* @date-time: 7/22/21 4:38 PM
///* @email: hrongyong@gmail.com
///* description: 
///* <fileName> <author> <date-time> <email> <description>
///* 文件名 作者姓名 创建时间 作者邮箱 文件描述
///*/
class BusinessCustomerDetailsTagEditLabelTabForm extends StatefulWidget {

  final List<dynamic> dataSource;

  final Map<String, dynamic> formDataSource;

  const BusinessCustomerDetailsTagEditLabelTabForm({Key key, this.dataSource, this.formDataSource}) : super(key: key);

  @override
  _BusinessCustomerDetailsTagEditLabelTabFormState createState() => _BusinessCustomerDetailsTagEditLabelTabFormState();
}

class _BusinessCustomerDetailsTagEditLabelTabFormState extends State<BusinessCustomerDetailsTagEditLabelTabForm> {
  BaseRequestFormProvider baseRequestFormProvider;

  @override
  void initState() {
    super.initState();
    List<BaseHttpRequestModel> _requests = this._initContentRequestFields();
    baseRequestFormProvider = BaseRequestFormProvider(requests: _requests, dataSource: widget.formDataSource);
  }
  @override
  Widget build(BuildContext context) {
    return Container();
  }

  /// 构建入参
  List<BaseHttpRequestModel> _initContentRequestFields() {
    List<dynamic> items = widget.dataSource ?? [];
    List<BaseHttpRequestModel> requests = [];
    items.forEach((element) {
      String accessMode = BaseUtils.getKeyData(element, 'accessMode').toString();
      String fieldName = BaseUtils.getKeyData(element, 'propertyId').toString();
      String name = BaseUtils.getKeyData(element, 'propertyName').toString();
      String notes = BaseUtils.getKeyData(element, 'propertyTag').toString();
      String inputApi = BaseUtils.getKeyData(element, 'inputApi').toString();
      String inputType = BaseUtils.getKeyData(element, 'inputType').toString();
      String defaultValue = BaseUtils.getKeyData(element, 'inputDefault').toString();
      String propertyRequired = BaseUtils.getKeyData(element, 'propertyRequired').toString();
      BaseHttpRequestModel request = new BaseHttpRequestModel.fromJson({'fieldName': fieldName, 'name': name, 'notes': notes, 'inputApi': inputApi, 'inputType': inputType, 'accessMode': accessMode, 'required': propertyRequired == 'true', 'defaultValue': defaultValue});
      requests.add(request);
    });
    return requests;
  }
}
